package cli.menu;

/**
 * BudgetBuoy
 * 
 * Simplify your personal expense management
 * 
 * @team cs2103jan13-w15-3j
 */

//--------------------------------------------------------------

/**
 * AddPaymentModes Class
 * 
 * Description: 
 * 
 * 
 * @package   cli.menu
 * @author    Lai Yong Quan (A0080909Y)
 * @edited by: Tan Si Ling (A0085314J)
 */

import cli.tools.Process;
import shared.*;


class AddPaymentMode extends Function{
	
	private static final String[] ADDMOD = {
	 "-= Main menu > Manage Payment Modes =-",
	"",
	"Enter the name for the new Payment Mode: "
	};
	
	private static final String[] FAIL = {
		"Failed to add Payment Mode"
	};
	
	private static State back = State.MANAGEPAYMENTMODES;
	private static State current = State.ADDPAYMENTMODE;
	
	public static State runMenu(){
		
		Mode paymentMode;
		String input= null;
		
		while(input == null || input.length() == 0){
			cli.print(ADDMOD);
			input = cli.nextLine();
			cli.clearScreen();
		}
		
		try{
			paymentMode= cli.getApi().addMode(input);
			}
			catch(Exception e){
				cli.print(FAIL);
				return current;
			}
		
		// Si Ling: **Keeping Track of the Actions DONE**
		tools.action.addToUndoStack((Object) null, paymentMode,
				Process.ADDPAYMENTMODES, (Object) null);
		// **END**
		
		return back;
		
	}
	
	
}

